#ifndef SESSIONDIALOG_H
#define SESSIONDIALOG_H

#include <QDialog>
#include <QStandardItemModel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTabWidget>
#include <QTextEdit>
#include <QTableView>
#include <QLabel>
#include <QHeaderView>
#include "session.h"
#include "common.h"

// 前向声明
class SessionManager;

class SessionDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SessionDialog(SessionManager *sessionManager, const ProtocolSession &session,
                          const QList<PacketInfo> &allPackets, QWidget *parent = nullptr);
    ~SessionDialog();

private slots:
    void onPacketTableClicked(const QModelIndex &index);

private:
    SessionManager *m_sessionManager;
    ProtocolSession m_session;
    QList<PacketInfo> m_allPackets;
    QList<PacketInfo> m_sessionPackets;
    
    QTabWidget *m_tabWidget;
    QTableView *m_packetTable;
    QTextEdit *m_sessionDetailText;
    QTextEdit *m_packetDetailText;
    
    QStandardItemModel *m_packetModel;
    
    void initUI();
    void populatePacketTable();
    void displaySessionDetails();
    void displayPacketDetails(const PacketInfo &packet);
    QList<PacketInfo> getSessionPackets();
};

#endif // SESSIONDIALOG_H